<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>学生成绩查询</title>
    <link rel="stylesheet" href="/layuimoduls/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuimoduls/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <table id="stuscore" lay-filter="test"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-sm " lay-event="detail">查看详情</a>
        </script>
    </div>
</div>
<script src="/layui/layui.js"></script>
<script src="/jquery/jquery-3.6.0.js"></script>
<script th:inline="none">
    layui.use('table', function () {
        var table = layui.table;
        var form =layui.form;

        //第一个实例
        table.render({
            elem: '#stuscore'
            , url: '/queryScore' //数据接口
            , method: 'post'
            , page: true //开启分页
            , cols:
                [
                    [
                        {field: 'testid', title: '考试ID'}
                        , {field: 'userid', title: '学生ID'}
                        , {field: 'testname', title: '考试名称'}
                        , {field: 'scores', title: '总成绩'},
                        {title: '操作', toolbar: '#currentTableBar', align: "center"}
                    ]
                ]
        });
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            var userid =data.userid;
            var testid = data.testid;
            if (obj.event === 'detail') {  // 监听查看试卷
                var index = layer.open({
                    title: '查看试卷',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: '/examdetail/'+userid +'/'+testid,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            }
        });
    });
</script>
</body>
</html>